package com.wjc.train.business.controller.admin;

import com.wjc.train.business.req.AdminLoginReq;
import com.wjc.train.business.req.AdminSendCodeReq;
import com.wjc.train.business.resp.AdminLoginResp;
import com.wjc.train.business.service.IAdminService;
import com.wjc.train.common.resp.CommonResp;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Guessed
 */
@RestController
@Validated
@RequestMapping("/admin")
public class AdminController {

    @Resource
    private IAdminService adminService;

    @PostMapping("/send-code")
    public CommonResp<Boolean> sendCode(@RequestBody @Valid AdminSendCodeReq adminSendCodeReq) {
        adminService.sendCode(adminSendCodeReq);
        return CommonResp.success();
    }

    @PostMapping("/login")
    public CommonResp<AdminLoginResp> login(@RequestBody @Valid AdminLoginReq adminLoginReq) {
        AdminLoginResp login = adminService.login(adminLoginReq);
        return CommonResp.success(login);
    }
}
